Skip to content

Add prompt section to game configs - #26

Merged
john-b-yang merged 6 commits into
mainfrom
john/prompts
Aug 14, 2025
Merged

Add prompt section to game configs#26
john-b-yang merged 6 commits into
mainfrom
john/prompts

Conversation

@john-b-yang

Copy link
Copy Markdown
Contributor

This PR introduces the prompts section of a CodeClash config. The prompts contain free form text + instructions that can + should be incorporated by whatever agentic editing scaffold (in our case, mini-swe-agent) is being used to facilitate an LM's ability to edit a codebase.

To standardize the game information that is available to an agent, this PR also replaces the template_vars variable with a GameContext dataclass that also facilitates the re-rendering of prompts as the game state changes across multiple rounds.

@john-b-yang
john-b-yang requested a review from klieret August 14, 2025 00:42
@john-b-yang

Copy link
Copy Markdown
Contributor Author

We don't have information indicating how many turns an agent has left. I will add this. I think this should be another prompt field that then gets inserted somewhere in the turn templates of mini-SWE-agent.

@klieret

klieret commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

We don't have information indicating how many turns an agent has left.

I think we can do that already with the action_observation_template

@klieret

klieret commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

ah nvm, we only have the model config, not its stats at the moment. I'll add that to mini in the future

@john-b-yang

Copy link
Copy Markdown
Contributor Author

Yeah exactly. Maybe this is something that's better to just build into mini directly? For this PR, I won't worry about it then.

Comment thread codeclash/agents/utils.py
rounds: int
working_dir: str

def render_and_set_prompts(self):

@klieret klieret Aug 14, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, this is because we need to render variables within the game description?

But wouldn't the clean way then simply be to have a render_prompts method that gets called when we use this object in the agent?

Why do we assign it with setattr and then later delete attrs in to_dict etc.? That feels pretty unnatural and confusing. Normally, we just want to track state in the object (without any duplication), and then either use properties or methods to transform it (but maybe I'm missing something)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok yeah this could be cleaner. But basically

  • we define a set of prompts in CodeClash configs
  • and then we define a set of prompts in Mini configs

The Mini config will reference ({{...}}) a prompt defined in the CodeClash config. But then the CodeClash config will reference the game state, and it needs to be updated as the game proceeds (e.g. round).

So then if i do Template(Mini template).render(CodeClash template), it won't populate the CodeClash template correctly with the metadata.

So this extra function is essentially to populate the CodeClash template first. Basically, this was the approach I came up to handle render a template, that is then rendered in another template.

There could be a more elegant way to do this. I was going for the simplest, most flexible solution. I think it's ok, but open to changing this if there's something obviously easier?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally happy to just merge this and if I can come up with something more elegant, I can just create a PR or something? I was thinking about this yesterday a little bit and I think there might be slightly more elegant ways to do this, but I need to experiment a bit (it would be equivalent)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sg sg yeah like we discussed in meeting - I'll resolve ur comments right now 🙏🏼 and then just merge, so we can just move on for now.

@john-b-yang
john-b-yang requested a review from klieret August 14, 2025 01:13
Comment thread configs/battlecode.yaml Outdated
Comment thread configs/battlecode.yaml Outdated
Comment thread configs/battlecode.yaml Outdated
Comment thread configs/battlecode.yaml Outdated
Comment thread configs/battlecode.yaml Outdated
@john-b-yang
john-b-yang merged commit a660496 into main Aug 14, 2025
1 check passed
@john-b-yang
john-b-yang deleted the john/prompts branch August 14, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants